﻿using MengLin.OOP.DesignPattern.State.RoomManagerSys.Entity;
using MengLin.OOP.DesignPattern.State.RoomManagerSys.Implements;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.State.RoomManagerSys
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 传统写法
            {
                string state = "空闲";
                if (state == "空闲")
                {
                    if (预定房间)
                    {
                        //预定操作
                        state = "已预定";
                    }
                    else if (住进房间)
                    {
                        //入住操作
                        state = "已入住";
                    }
                }
                else if (state == "已预定")
                {
                    if (住进房间)
                    {
                        //入住操作
                        state = "已入住";
                    }
                    else if (取消预定)
                    {
                        //取消预定操作
                        state = "空闲";
                    }
                }
            }
            #endregion

            //房间的空闲，预定，入住状态
            Room room = new Room();//Context：拥有状态的对象
            //空闲
            Console.WriteLine("==================================");
            room.SetState(new FreeState());
            Console.WriteLine(room.GetState());

            //办理入住
            Console.WriteLine("==================================");
            room.CheckIn();
            Console.WriteLine(room.GetState());

            //办理退房
            Console.WriteLine("==================================");
            room.CheckOut();
            Console.WriteLine(room.GetState());

            //办理退房
            Console.WriteLine("==================================");
            room.CheckOut();
            Console.WriteLine(room.GetState());
            Console.ReadKey();
        }
    }
}
